#include "../lib/define.h"

#define DEV_8259A_INIT_MAGIC_BIT 0x00000010
#define DEV_8259A_INIT_EDGE_TRIGGERED_MODE 0x00000000
#define DEV_8259A_INIT_LEVEL_TRIGGERED_MODE 0x00000008
#define DEV_8259A_INIT_VECTOR_8 0x00000000
#define DEV_8259A_INIT_VECTOR_4 0x00000004
#define DEV_8259A_INIT_CASCADE_MODE 0x00000000
#define DEV_8259A_INIT_SINGLE_MODE 0x00000002
#define DEV_8259A_INIT_NO_ICW4 0x00000000
#define DEV_8259A_INIT_NEED_ICW4 0x00000001
#define DEV_8259A_INIT_INT_VECTOR_BASE(base) (((DWORD)base) << 8)
#define DEV_8259A_INIT_SLAVE(mask) (((DWORD)(BYTE)mask) << 16)
#define DEV_8259A_INIT_SLAVE_ATTACH(pos) (((DWORD)(BYTE)pos) << 16)
#define DEV_8259A_INIT_NO_SPECIAL_FULLY_NESTED_MODE 0x00000000
#define DEV_8259A_INIT_SPECIAL_FULLY_NESTED_MODE 0x10000000
#define DEV_8259A_INIT_NONBUFFERED_MODE 0x00000000
#define DEV_8259A_INIT_BUFFERED_MODE_SLAVE 0x08000000
#define DEV_8259A_INIT_BUFFERED_MODE_MASTER 0x0C000000
#define DEV_8259A_INIT_NORMAL_EOI 0x00000000
#define DEV_8259A_INIT_AUTO_EOI 0x02000000
#define DEV_8259A_INIT_8085_MODE 0x00000000
#define DEV_8259A_INIT_8086_8088_MODE 0x01000000

void Dev8259AFirstInitialize(DWORD dwAttribute);
#define Dev8259AFirstGetInterruptMask(lpbMask) __asm__("in $0x21,%%al":"=a"(*lpbMask))
#define Dev8259AFirstSetInterruptMask(bMask) __asm__("out %%al,$0x21"::"a"(bMask))
void Dev8259AFirstSetOCW2(BYTE bVal);
void Dev8259AFirstSetOCW3(BYTE bVal);
void Dev8259AFirstReadIntrruptRequestRegister(LPBYTE lpbReg);
void Dev8259AFirstReadIntrruptInServiceRegister(LPBYTE lpbReg);

void Dev8259ASecondInitialize(DWORD dwAttribute);
#define Dev8259ASecondGetInterruptMask(lpbMask) __asm__("in $0xA1,%%al":"=a"(*lpbMask))
#define Dev8259ASecondSetInterruptMask(bMask) __asm__("out %%al,$0xA1"::"a"(bMask))
void Dev8259ASecondSetOCW2(BYTE bVal);
void Dev8259ASecondSetOCW3(BYTE bVal);
void Dev8259ASecondReadIntrruptRequestRegister(LPBYTE lpbReg);
void Dev8259ASecondReadIntrruptInServiceRegister(LPBYTE lpbReg);
